import http from './http'
// 普通登录
export function usernameLogin(username, password) {
    let params = new URLSearchParams
    params.append('username', username)
    params.append('rememberMe', "false")
    params.append('password', password)
    return http.post('/api/api/login', params)
}
//   注册
export function getRegister(loginName, code, phonenumber, password, userName) {
    let params = new URLSearchParams
    params.append('loginName', loginName)//zhanghao
    params.append('code', code)//验证码
    params.append('phonenumber', phonenumber)//手机号
    params.append('password', password)//密码
    params.append('userName', userName)//nicheng
    return http.post(`/api/api/registry`, params)
}
// 验证码
export function getCode(mobile) {
    return http.get(`/api/api/short-message/vcode/${mobile}`)
}
// 忘记密码
export function forgetCode(loginName, code, phonenumber, password) {
    let params = new URLSearchParams
    params.append('loginName', loginName)//zhanghao
    params.append('code', code)//验证码
    params.append('phonenumber', phonenumber)//手机号
    params.append('password', password)//密码
    return http.post(`/api/api/password/forget`, params)
}
// 退出登录
export function logout() {
    return http.get('/api/api/logout')
}

// 查看个人信息
export function checkInfo() {
    return http.get('/api/api/login-user/info')
}
// 修改个人信息userName,phonenumber
export function resetInfo(userName) {
    let params = new URLSearchParams();
    params.append('userName', userName)
    // params.append('phonenumber', phonenumber)
    return http.post(`/api/api/system/user/profile/update`,params)
}
// 修改头像
export function getTou(avatarfile) {
    let params = new FormData
    params.append('avatarfile', avatarfile)
    return http.post('/api/api/system/user/profile/update/avatar/nos', params)
}
//热门新闻接口封装post请求
export function hotnews(pageNum, pageSize) {
    let params = new URLSearchParams();
    params.append('pageNum', pageNum)
    params.append('pageSize', pageSize)
    const url = `/api/api/cms/article/open/hot/list`
    return http.post(url, params)
}
//新闻详情
export function newdetail(articleId) {
    const url = `/api/api/cms/article/open/detail/${articleId}`
    return http.get(url, { "articleId": articleId })
}
// 收藏
export function collectNew(articleId) {
    return http.get(`/api/api/cms/collect/collect/article/${articleId}`)
}
// 收藏文章列表
export function collectNewList() {
    return http.get(`/api/api/cms/article/collect/list`)
}
// 点赞
export function getZan(articleId) {
    return http.get(`/api/api/cms/article/add/zan/${articleId}`)
}

//分类列表
export function getNewslist(pageNum, pageSize) {
    let params = new URLSearchParams();
    params.append('pageNum', pageNum)
    params.append('pageSize', pageSize)
    const url = `/api/api/cms/category/open/list`
    return http.post(url, params);
}

// 轮播图
export function getSwiper() {
    return http.post(`/api/api/cms/article/open/banner/list`);
}
// 首页新闻
export function getNews(title) {
    let params = new URLSearchParams();
    params.append('pageNum', 1)
    params.append('pageSize', 10)
    params.append('title', title)
    return http.post(`/api/api/cms/article/open/list`, params);
}
// 天气预报，天气种类列表
export function weather_wids() {
    let params = new URLSearchParams
    // key
    params.append("key", "3c315cb464e3e857932152d5e02ac4db")
    return http("/japi/simpleWeather/wids", params)
}






// 2021春运防疫政策，城市ID查询
export function outcity() {
    let params = new URLSearchParams
    // key
    params.append("key", "2c8f08f67928a008aad323a3d988ed2c")
    return http.post("/japi/springTravel/citys", params)
}
//2021春运防疫政策查询
export function outbreak(from, to) {
    let params = new URLSearchParams
    // key
    params.append("key", "2c8f08f67928a008aad323a3d988ed2c")
    // 出发城市id
    params.append("from", from)
    // 到达城市ID
    params.append("to", to)
    return http.post("/japi/springTravel/query", params)
}

// 天气预报
// 天气预报，支持程序列表
export function weather_city() {
    let params = new URLSearchParams
    // key
    params.append("key", "3c315cb464e3e857932152d5e02ac4db")
    return http.post("/japi/simpleWeather/cityList", params)
}

// 天气预报，根据城市ID查询生活指数
export function weather_lifes(city) {
    let params = new URLSearchParams
    // key
    params.append("key", "3c315cb464e3e857932152d5e02ac4db")
    // city
    params.append("city", city)
    return http.post("/japi/simpleWeatherPfe", params)
}
// 天气预报，根据城市ID查询天气
export function weather(city) {
    let params = new URLSearchParams
    // key
    params.append("key", "3c315cb464e3e857932152d5e02ac4db")
    // city
    params.append("city", city)
    return http.post("/japi/simpleWeather/query", params)
}
